package cc.autoapi.pucong.auto.flow.persistence.repository.api;


import cc.autoapi.pucong.auto.flow.core.root.entity.UserJwt;
import cc.autoapi.pucong.auto.flow.persistence.po.api.ApiInfoPo;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @description:
 * @author: cong.pu
 * @create: 2024-11-04 15:07
 **/
public interface AutoFlowAuthInterceptor {

    /**
     * 登录校验是否可以登录
     *
     * @param userName
     * @param password
     * @return
     */
    Boolean checkLogin(String userName, String password);

    /**
     * 校验当前是否已经登录
     *
     * @param request
     * @return
     */
    Boolean isLogin(HttpServletRequest request);

    /**
     * 获取当前登录用户
     *
     * @param request
     * @return
     */
    UserJwt getLoginUser(HttpServletRequest request);

    /**
     * 退出登录
     *
     * @param request
     * @return
     */
    void loginOut(HttpServletRequest request);

    /**
     * 查询服务列表时，过滤数据
     *
     * @param apiInfos
     * @return
     */
    default List<ApiInfoPo> fitterApiList(List<ApiInfoPo> apiInfos){
        return apiInfos;
    }

    /**
     * 执行时，校验权限
     *
     * @param request
     * @param apiInfoPo
     * @return
     */
    default Boolean checkExecPermission(HttpServletRequest request, ApiInfoPo apiInfoPo){
        return true;
    }
}
